﻿using System.Globalization;
using System.Net.Http;
using CkSoftware.GroupMe.Sdk.Core;
using CkSoftware.GroupMe.Sdk.Core.Dao;
using CkSoftware.GroupMe.Sdk.Groups.Dao;

namespace CkSoftware.GroupMe.Sdk.Groups.Commands
{
	/// <summary>
	/// Group remove member command (GroupMe documentation: <see href="https://dev.groupme.com/docs/v3#members_remove" />).
	/// </summary>
	public class GroupRemoveMemberCommand : IWebApiCommand<GroupMeApiResponse<EmptyResponse>>
	{
		private const string CommandNameFormat = "/groups/{0}/members/{1}/remove";
		private readonly string _groupId;
		private readonly string _memberId;

		/// <summary>
		/// Instantiates a new <see cref="GroupRemoveMemberCommand" /> using the given groupId and groupMemberId.
		/// </summary>
		/// <param name="groupId">The group for which a member should be removed.</param>
		/// <param name="groupMemberId">The groupMemberId for the member to remove. Attention: this is the Id parameter of the <see cref="GroupMemberData"/>, not the UserId!</param>
		public GroupRemoveMemberCommand(string groupId, string groupMemberId)
		{
			_groupId = groupId;
			_memberId = groupMemberId;
		}

		/// <summary>
		/// Defines if the command is executed once.
		/// </summary>
		public bool CommandExecuted { get; set; }

		/// <summary>
		/// The name of the command to be executed.
		/// </summary>
		public string CommandName
		{
			get { return string.Format(CultureInfo.CurrentCulture, CommandNameFormat, _groupId, _memberId); }
		}

		/// <summary>
		/// The http method to execute this command.
		/// </summary>
		public HttpMethod HttpMethod
		{
			get { return HttpMethod.Post; }
		}

		/// <summary>
		/// The parameters which should be used on command execution.
		/// </summary>
		public IWebApiCommandParameters Parameters
		{
			get { return null; }
		}
	}
}